/*
 * @file     g_memcp.h
 * @brief    source file for setting memcp
 *
 * Change Logs:
 * Date            Author             Version        Notes
 * 2020-12-31      wanghongwei         V1.0.0        the first version
 * 2021-11-08      wanghongwei         V1.0.1        Changing register name
 */

#include "g_memcp.h"

/**
 * @method  MEMCP_Init
 * @brief   Init MEMCP
 * @param   MEMCP : the memcp dam moudle selection
 * @param   MEMCP_InitStruct : MEMCP initializes the structure
 * @retval  none
 */
void MEMCP_Init(DMA_TypeDef *MEMCP, MEMCP_InitTypeDef *MEMCP_InitStruct)
{
    _ASSERT(IS_MEMCP(MEMCP));

    MEMCP->CTRL.bit.RESET = 1;
    MEMCP->CTRL.bit.RESET = 0;
    MEMCP->SRC_ADDR.reg =(MEMCP_InitStruct->SRC);
    MEMCP->DEST_ADDR.reg = (MEMCP_InitStruct->DES);
    MEMCP->LEN_LOW.bit.RX_LEN_L = MEMCP_InitStruct->D_LEN;
    MEMCP->LEN_LOW.bit.TX_LEN_L = MEMCP_InitStruct->S_LEN;
}

/**
 * @method  MEMCP_Cmd
 * @brief   enable or disable memcp
 * @param   MEMCP : the memcp dam moudle selection
 * @retval  none
 */
void MEMCP_Cmd(DMA_TypeDef *MEMCP)
{
    _ASSERT(IS_MEMCP(MEMCP));

    MEMCP->CTRL.bit.START = 1;
}

/**
 * @method  MEMCP_ITConfig
 * @brief   Enable or disable the MEMCP interrupt
 * @param   MEMCP : the memcp dam moudle selection
 * @param   INT_STATE :Fixed G_FunctionalState enumeration type
 * @retval  none
 */
void MEMCP_ITConfig(DMA_TypeDef *MEMCP, G_FunctionalState INT_STATE)
{
    _ASSERT(IS_MEMCP(MEMCP));

    MEMCP->CTRL.bit.INT_MODE = INT_STATE;
}

/**
 * @method  MEMCP_ClearITBit
 * @brief   Clear the MEMCP interrupt
 * @param   MEMCP : the memcp dam moudle selection
 * @retval  none
 */
void MEMCP_ClearITBit(DMA_TypeDef *MEMCP)
{
    _ASSERT(IS_MEMCP(MEMCP));

    MEMCP->CTRL.bit.CLEAR_INT = 1;
}

/**
 * @method  MEMCP_GETITStatus
 * @brief   Get the specific MEMCP interrupt status
 * @param   MEMCP : the memcp dam moudle selection
 * @retval  The new state of specific MEMCP IT_Flag(SET or RESET)
 */
G_ITStatus MEMCP_GETITStatus(DMA_TypeDef *MEMCP)
{
    _ASSERT(IS_MEMCP(MEMCP));

    if(MEMCP->STATUS.bit.DONE != RESET)
    {
        return SET;
    }
    return RESET;
}

/************************ (C) COPYRIGHT GKT *****END OF FILE****/
